home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Gobby 0.4.7 / gobby-0.4.7.exe / {app} / share / gtksourceview-2.0 / language-specs / c.lang < prev    next >
Extensible Markup Language  |  2008-09-09  |  12KB  |  272 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.  Authors: Marco Barisione, Emanuele Aina
  5.  Copyright (C) 2005-2007 Marco Barisione <barisione@gmail.com>
  6.  Copyright (C) 2005-2007 Emanuele Aina
  7.  
  8.  This library is free software; you can redistribute it and/or
  9.  modify it under the terms of the GNU Library General Public
  10.  License as published by the Free Software Foundation; either
  11.  version 2 of the License, or (at your option) any later version.
  12.  
  13.  This library is distributed in the hope that it will be useful,
  14.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  Library General Public License for more details.
  17.  
  18.  You should have received a copy of the GNU Library General Public
  19.  License along with this library; if not, write to the
  20.  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21.  Boston, MA 02111-1307, USA.
  22.  
  23. -->
  24. <language id="c" _name="C" version="2.0" _section="Sources">
  25.     <metadata>
  26.       <property name="mimetypes">text/x-c;text/x-csrc;image/x-xpixmap</property>
  27.       <property name="globs">*.c</property>
  28.       <property name="line-comment-start">//</property>
  29.       <property name="block-comment-start">/*</property>
  30.       <property name="block-comment-end">*/</property>
  31.     </metadata>
  32.  
  33.     <styles>
  34.         <style id="comment"           _name="Comment"             map-to="def:comment"/>
  35.         <style id="error"             _name="Error"               map-to="def:error"/>
  36.         <style id="string"            _name="String"              map-to="def:string"/>
  37.         <style id="preprocessor"      _name="Preprocessor"        map-to="def:preprocessor"/>
  38.         <style id="common-defines"    _name="Common Defines"      map-to="def:special-constant"/>
  39.         <style id="included-file"     _name="Included File"       map-to="def:string"/>
  40.         <style id="char"              _name="Character"           map-to="def:character"/>
  41.         <style id="keyword"           _name="Keyword"             map-to="def:keyword"/>
  42.         <style id="type"              _name="Data Type"           map-to="def:type"/>
  43.         <style id="storage-class"     _name="Storage Class"       map-to="def:type"/>
  44.         <style id="printf"            _name="printf Conversion"   map-to="def:character"/>
  45.         <style id="escaped-character" _name="Escaped Character"   map-to="def:special-char"/>
  46.         <style id="floating-point"    _name="Floating point number" map-to="def:floating-point"/>
  47.         <style id="decimal"           _name="Decimal number"      map-to="def:decimal"/>
  48.         <style id="octal"             _name="Octal number"        map-to="def:base-n-integer"/>
  49.         <style id="hexadecimal"       _name="Hexadecimal number"  map-to="def:base-n-integer"/>
  50.         <style id="boolean"           _name="Boolean value"       map-to="def:boolean"/>
  51.     </styles>
  52.  
  53.     <definitions>
  54.         <!-- TODO: what about scanf ? -->
  55.         <!-- man 3 printf -->
  56.         <context id="printf" style-ref="printf" extend-parent="false">
  57.             <match extended="true">
  58.                 \%\%|\%
  59.                 (?:[1-9][0-9]*\$)?      # argument
  60.                 [#0\-\ \+\'I]*          # flags
  61.                 (?:[1-9][0-9]*|\*)?     # width
  62.                 (?:\.\-?(?:[0-9]+|\*))? # precision
  63.                 (?:hh|ll|[hlLqjzt])?    # length modifier
  64.                 [diouxXeEfFgGaAcsCSpnm] # conversion specifier
  65.             </match>
  66.         </context>
  67.  
  68.         <define-regex id="escaped-character" extended="true">
  69.             \\(                   # leading backslash
  70.             [\\\"\'nrbtfav\?] |   # escaped character
  71.             [0-7]{1,3} |          # one, two, or three octal digits
  72.             x[0-9A-Fa-f]+         # 'x' followed by hex digits
  73.             )
  74.         </define-regex>
  75.  
  76.         <context id="c">
  77.             <include>
  78.  
  79.                 <!-- gtk-doc -->
  80.                 <context ref="gtk-doc:inline-docs-section"/>
  81.  
  82.                 <!-- Comments -->
  83.                 <context id="comment" style-ref="comment" end-at-line-end="true">
  84.                     <start>//</start>
  85.                     <include>
  86.                       <context ref="def:in-line-comment"/>
  87.                     </include>
  88.                 </context>
  89.  
  90.                 <context id="comment-multiline" style-ref="comment">
  91.                     <start>/\*</start>
  92.                     <end>\*/</end>
  93.                     <include>
  94.                         <context ref="def:in-comment"/>
  95.                     </include>
  96.                 </context>
  97.  
  98.                 <context id="close-comment-outside-comment" style-ref="error">
  99.                     <match>\*/(?!\*)</match>
  100.                 </context>
  101.  
  102.                 <!-- Preprocessor -->
  103.                 <define-regex id="preproc-start">^\s*#\s*</define-regex>
  104.  
  105.                 <context id="if0-comment" style-ref="comment">
  106.                     <start>\%{preproc-start}if\b\s*0\b</start>
  107.                     <end>\%{preproc-start}(endif|else|elif)\b</end>
  108.                     <include>
  109.                         <context id="if-in-if0">
  110.                             <start>\%{preproc-start}if(n?def)?\b</start>
  111.                             <end>\%{preproc-start}endif\b</end>
  112.                             <include>
  113.                                 <context ref="if-in-if0"/>
  114.                                 <context ref="def:in-comment"/>
  115.                             </include>
  116.                         </context>
  117.                         <context ref="def:in-comment"/>
  118.                     </include>
  119.                 </context>
  120.  
  121.                 <context id="include" style-ref="preprocessor">
  122.                     <match extended="true">
  123.                             \%{preproc-start}
  124.                             (include|import)\s*
  125.                             (".*?"|<.*>)
  126.                     </match>
  127.                     <include>
  128.                         <context id="included-file" sub-pattern="2" style-ref="included-file"/>
  129.                     </include>
  130.                 </context>
  131.  
  132.                 <context id="preprocessor" style-ref="preprocessor" end-at-line-end="true">
  133.                     <start extended="true">
  134.                             \%{preproc-start}
  135.                             (define|undef|error|pragma|ident|if(n?def)?|else|elif|endif|line|warning)
  136.                             \b
  137.                     </start>
  138.                     <include>
  139.                         <context ref="def:line-continue" ignore-style="true"/>
  140.                         <context ref="string" ignore-style="true"/>
  141.                         <context ref="comment"/>
  142.                         <context ref="comment-multiline"/>
  143.                     </include>
  144.                 </context>
  145.  
  146.                 <context id="string" style-ref="string" end-at-line-end="true">
  147.                     <start>L?"</start>
  148.                     <end>"</end>
  149.                     <include>
  150.                         <context ref="printf"/>
  151.                         <context id="escaped-character" style-ref="escaped-character">
  152.                             <match>\%{escaped-character}</match>
  153.                         </context>
  154.                         <context ref="def:line-continue"/>
  155.                     </include>
  156.                 </context>
  157.  
  158.                 <context id="char" style-ref="char">
  159.                     <match>L?'(\%{escaped-character}|.)'</match>
  160.                 </context>
  161.  
  162.                 <!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -->
  163.                 <context id="float" style-ref="floating-point">
  164.                     <match extended="true">
  165.                         (?<![\w\.])
  166.                         ((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? |
  167.                          ([0-9]+[Ee][+-]?[0-9]*))
  168.                         [fFlL]?
  169.                         (?![\w\.])
  170.                     </match>
  171.                 </context>
  172.  
  173.                 <context id="hexadecimal" style-ref="hexadecimal">
  174.                     <match extended="true">
  175.                         (?<![\w\.])
  176.                         0[xX][a-fA-F0-9]+[uUlL]*
  177.                         (?![\w\.])
  178.                     </match>
  179.                 </context>
  180.  
  181.                 <context id="octal" style-ref="octal">
  182.                     <match extended="true">
  183.                         (?<![\w\.])
  184.                         0[0-7]+[uUlL]*
  185.                         (?![\w\.])
  186.                     </match>
  187.                 </context>
  188.  
  189.                 <context id="decimal" style-ref="decimal">
  190.                     <match extended="true">
  191.                         (?<![\w\.])
  192.                         [0-9]+[uUlL]*
  193.                         (?![\w\.])
  194.                     </match>
  195.                 </context>
  196.  
  197.                 <!-- Keywords -->
  198.                 <context id="keywords" style-ref="keyword">
  199.                     <keyword>asm</keyword>
  200.                     <keyword>break</keyword>
  201.                     <keyword>case</keyword>
  202.                     <keyword>continue</keyword>
  203.                     <keyword>default</keyword>
  204.                     <keyword>do</keyword>
  205.                     <keyword>else</keyword>
  206.                     <keyword>enum</keyword>
  207.                     <keyword>for</keyword>
  208.                     <keyword>fortran</keyword>
  209.                     <keyword>goto</keyword>
  210.                     <keyword>if</keyword>
  211.                     <keyword>return</keyword>
  212.                     <keyword>sizeof</keyword>
  213.                     <keyword>struct</keyword>
  214.                     <keyword>switch</keyword>
  215.                     <keyword>typedef</keyword>
  216.                     <keyword>union</keyword>
  217.                     <keyword>while</keyword>
  218.                 </context>
  219.  
  220.                 <context id="types" style-ref="type">
  221.                     <keyword>_Bool</keyword>
  222.                     <keyword>_Complex</keyword>
  223.                     <keyword>_Imaginary</keyword>
  224.                     <keyword>bool</keyword>
  225.                     <keyword>char</keyword>
  226.                     <keyword>double</keyword>
  227.                     <keyword>float</keyword>
  228.                     <keyword>int</keyword>
  229.                     <keyword>long</keyword>
  230.                     <keyword>short</keyword>
  231.                     <keyword>signed</keyword>
  232.                     <keyword>size_t</keyword>
  233.                     <keyword>unsigned</keyword>
  234.                     <keyword>void</keyword>
  235.                 </context>
  236.  
  237.                 <context id="storage-class" style-ref="storage-class">
  238.                     <keyword>auto</keyword>
  239.                     <keyword>const</keyword>
  240.                     <keyword>extern</keyword>
  241.                     <keyword>inline</keyword>
  242.                     <keyword>register</keyword>
  243.                     <keyword>restrict</keyword>
  244.                     <keyword>static</keyword>
  245.                     <keyword>volatile</keyword>
  246.                 </context>
  247.  
  248.                 <context id="common-defines" style-ref="common-defines">
  249.                     <keyword>NULL</keyword>
  250.                     <keyword>MAX</keyword>
  251.                     <keyword>MIN</keyword>
  252.                     <keyword>TRUE</keyword>
  253.                     <keyword>FALSE</keyword>
  254.                     <keyword>__LINE__</keyword>
  255.                     <keyword>__DATA__</keyword>
  256.                     <keyword>__FILE__</keyword>
  257.                     <keyword>__func__</keyword>
  258.                     <keyword>__TIME__</keyword>
  259.                     <keyword>__STDC__</keyword>
  260.                 </context>
  261.  
  262.                 <!-- C99 booleans -->
  263.                 <context id="boolean" style-ref="boolean">
  264.                     <keyword>true</keyword>
  265.                     <keyword>false</keyword>
  266.                 </context>
  267.  
  268.             </include>
  269.         </context>
  270.     </definitions>
  271. </language>
  272.